package com.rattsoftware.client.service;

import java.util.List;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.rattsoftware.server.admin.model.Department;
import com.rattsoftware.server.admin.model.User;
import com.rattsoftware.server.admin.model.exceptions.RattsSecurityException;
import com.rattsoftware.server.admin.model.paging.PagingLoadConfig;
import com.rattsoftware.server.admin.model.paging.PagingLoadResult;

/**
 * Defines the client side contract for the Department Service.
 */
@RemoteServiceRelativePath("department")
public interface DepartmentService extends RemoteService {

	/**
	 * Returns a given Department given the ID.
	 * 
	 * @param departmentId
	 *            Id of the Department to retrieve.
	 * @return Department
	 */
	Department getDepartment(int departmentId) throws RattsSecurityException;
	
	/**
	 * Deletes the department data.
	 * 
	 * @param department
	 */
	void deleteDepartment(Department department) throws RattsSecurityException;

	/**
	 * Deletes all the submitted data specified by the IDs 
	 * 
	 * @param departmentIds
	 * @throws RattsSecurityException
	 */
	void deleteDepartment(List<Integer> departmentIds) throws RattsSecurityException;
	
	/**
	 * Calculates the number of course under a given department.
	 * 
	 * @param departmentId
	 * @return Integer (positive number, 0 for no courses)
	 */
	Integer getCourseCount(int departmentId) throws RattsSecurityException;
	
	/**
	 * Retrieves a page of the Department data.
	 * 
	 * @param user
	 *            User
	 * @param pagingLoadConfig
	 *            config to specify paging related config
	 * @return PagingLoadResult containing a page of department data
	 */
	PagingLoadResult<Department> getDepartmentList( User user, PagingLoadConfig pagingLoadConfig) throws RattsSecurityException;
	
	/**
	 * Saves a new and modified department to the database.
	 * 
	 * @param department the department to save.
	 * @return department saved with id populated
	 * @throws RattsSecurityException For any <tt>security related</tt> that occurs on the <tt>service layer.</tt>
	 */
	Department saveDepartment(Department department) throws RattsSecurityException;
	
	/**
	 * Persists a given list of departments to the database.
	 * 
	 * @param departments List of departments to persist.
	 */
	void saveDepartments(List<Department> departments) throws RattsSecurityException;
}
